package com.example.wxy.bbtapp.Service;

import org.xutils.http.RequestParams;
import org.xutils.x;

import com.example.wxy.bbtapp.Common.HttpHelper;
import com.example.wxy.bbtapp.Startup.AppSettings;
import com.example.wxy.bbtapp.Common.httpCallBack;

/**
 * Created by wxy on 2017/9/6.
 */

public class httpservice {
    private static httpservice httpservice;
    String Cook = "";
    String loginStr = "";
    private httpservice(){
    }
    public static httpservice getInstance(){
        if(httpservice==null){
            httpservice=new httpservice();
        }
        return httpservice;
    }
//登陆的操作
    public void login(httpCallBack<String> callBack){
        String  loginName = "zy";
        String  passWord = "123456";

        new HttpHelper("RestApi/SysUser/login")
                .addParameter("LoginName", loginName)
                .addParameter("PassWord", passWord)
                .post(callBack);
    }
    //绑定学校的值
    public void getSchoolData(String cook,httpCallBack<String> callBack){
        new HttpHelper("RestApi/Agent/GetAgentSchool")
                .addParameter("_IsPaging", "false")
                .post(callBack);

    }
   //绑定jiaoshi的值
   public void getclassData(String cook,String basicUrl,String schoolId, httpCallBack<String> callBack){

       new HttpHelper("RestApi/Agent/GetAuditedClassAdjust")
               .addParameter("_IsPaging", "false")
               .addParameter("school_id", schoolId)
               .post(callBack);

   }
   //根据学校去获取服务器地址
    public void getBasicUrl(String schoolId,String cook,httpCallBack<String> callBack){

        new HttpHelper("RestApi/Agent/GetSiteIpAddress?school_id="+schoolId)
                .post(callBack);
    }

    //绑定设备
    public void bindEquipment(String DeviceID, String cook, String schoolID, String name, String mac, String version, String ip, String ClassRoomId, String CreateDate, httpCallBack<String> callBack) {

        new HttpHelper("RestApi/TerminalInfo/Insert")
                .addParameter("_IsPaging", "true")
                .addParameter("SchoolID", schoolID)
                .addParameter("Name",name)
                .addParameter("ID",DeviceID)
                .addParameter("Version",version)
                .addParameter("IP",ip)
                .addParameter("ClassRoomID",ClassRoomId)
                .addParameter("Categroy","4")
                .addParameter("TerStatus","1")
                .addParameter("CreateDate",CreateDate)
                .addParameter("Mac",mac)
                .post(callBack);
    }


    //获取版本号
    public void getAppVersion(httpCallBack<String> callBack){
        RequestParams requestParams = new RequestParams(AppSettings.url+"RestApi/SystemSet/GetAPKConfig");
        requestParams.addParameter("","");
        x.http().post(requestParams,callBack);
    }

}
